package com.tbit.uqbike.client.util;

import com.tbit.common.constant.BizCode;
import com.tbit.uqbike.client.constant.RechargeConstant;
import com.tbit.utils.order.*;

/**
 * @Author: chen
 * @Description:
 * @Date: 创建于 15:39 2022/11/14
 */
public class OrderNoUtil {

    /**
     * 生成订单号
     *
     * @param num  随机数
     * @param type 订单编号
     * @return
     */
    public static String getOrderNO(Long num, Integer type) {
        OrderNoProducter onp = OrderNoProducter
                .buildOrderNoProducter(ComEnum.COM_TBIT, ProductBlocEnum.BLOC_GX, ProductEnum.PRO_GX);
        // 使用构建器生成一个流水号（第一个入参是业务代码，为了区分不同订单的用途，各个业务代码在业务系统自行定义，第二个是流水号，各个业务系统自行生产，保证唯一性）
        OrderNo on = onp.genOrderNo(BizCode.PAY.getCode(), num);
        switch (type) {
            case RechargeConstant.recharge_Mem:
                on = onp.genOrderNo(BizCode.MEM.getCode(), num);
                break;
            case RechargeConstant.recharge_rideCard:
                on = onp.genOrderNo(BizCode.CARD.getCode(), num);
                break;
            case RechargeConstant.recharge_vip:
                on = onp.genOrderNo(BizCode.VIP.getCode(), num);
                break;
            case RechargeConstant.recharge_meal:
                on = onp.genOrderNo(BizCode.MEAL.getCode(), num);
                break;
            case RechargeConstant.recharge_deposit:
                on = onp.genOrderNo(BizCode.DEPOSIT.getCode(), num);
                break;
            case RechargeConstant.recharge_exempt:
                on = onp.genOrderNo(BizCode.EXEMPT.getCode(), num);
                break;
            case RechargeConstant.recharge_returnBike:
                on = onp.genOrderNo(BizCode.RIDE.getCode(), num);
                break;
            case RechargeConstant.recharge_zff:
                on = onp.genOrderNo(BizCode.WXZFF.getCode(), num);
                break;
            case 1000:
                on = onp.genOrderNo(BizCode.RIDELOG.getCode(), num);
                break;
            case 1001:
                on = onp.genOrderNo(BizCode.SIGN.getCode(), num);
                break;
            default:
                break;
        }
        return on.toOrderString();
    }

    public static String getRefundNO() {
        OrderNoProducter onp = OrderNoProducter
                .buildOrderNoProducter(ComEnum.COM_TBIT, ProductBlocEnum.BLOC_GX, ProductEnum.PRO_GX);
        OrderNo on = onp.genOrderNo(BizCode.REFUND.getCode(), (long) TenpayUtil.buildRandom(6));
        return on.toOrderString();
    }
}
